$(function () {
    var orderId = $("#orderId").val();
    $("#jqGrid").jqGrid({
        url: baseURL + 'orderitem/list',
        postData:{
            'orderId': orderId
        },
        datatype: "json",
        colModel: [
			{ label: '供应商', name: 'shopName', index: 'shop_name', width: 70 },
			{ label: '产品名', name: 'productName', index: 'product_name', width: 60 },
			{ label: '数量', name: 'number', index: 'number', width: 50 },
			{ label: '单位', name: 'unit', index: 'unit', width: 50 },
			{ label: '材质', name: 'material', index: 'material', width: 60 },
			{ label: '型号', name: 'model', index: 'model', width: 60 },
			{ label: '单价', name: 'price', index: 'price', width: 50 },
			{ label: '总价', name: 'totalPrice', index: 'totalPrice', width: 50  },
			{ label: '创建时间', name: 'createTime', index: 'create_time', width: 100,
                formatter:'date',formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i:s'}},
			{ label: '备注', name: 'remark', index: 'remark', width: 120 }
        ],
		viewrecords: false,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true,
        rownumWidth: 25, 
        autowidth:true,
        multiselect: false,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page",
            rows:"limit",
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
		title: null,
		order: {
        }
	},
	methods: {
		update: function (event) {
            $.ajax({
                type: "POST",
                url: baseURL + "orders/update",
                contentType: "application/json",
                data: JSON.stringify({"id":$("#orderId").val(),"logisticsFee":$("#logisticsFee").val()}),
                success: function(r){
                    if(r.code == 0){
                        alert('操作成功');
                    }else{
                        alert(r.msg);
                    }
                }
            });
		},
        preview: function (event) {
            window.open("/sys/orders/preview?orderId="+$("#orderId").val());
        },
        back: function (event) {
            window.location.href = baseURL + 'orders/back';
        },
		reload: function (event) {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam',{ 
                page:page
            }).trigger("reloadGrid");
		}
	}
});